package com.xk857.simpleeffect.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.xk857.simpleeffect.R;
import com.xk857.simpleeffect.domain.vo.CustomerBusinessSimpleVO;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class ListFriendCollaborationAdapter extends BaseQuickAdapter<CustomerBusinessSimpleVO, ListFriendCollaborationAdapter.ViewHolder> {

    private final Context mContext;


    public ListFriendCollaborationAdapter(Context context, List<CustomerBusinessSimpleVO> voList) {
        super(voList);
        this.mContext = context;
    }


    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, int i, @Nullable CustomerBusinessSimpleVO vo) {
        Glide.with(mContext).load(vo.getHeadImg()).into(holder.headImg);
        holder.nickNameText.setText(vo.getNickName());
        if (!vo.getRole().equals(0)) {
            holder.isAdminText.setVisibility(View.VISIBLE);
            holder.headImg.setBorderColor(mContext.getColor(R.color.main_border));
        }
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup parent, int i) {
        return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.list_collaboration_friend, parent, false));
    }


    static class ViewHolder extends RecyclerView.ViewHolder {
        CircleImageView headImg;
        TextView nickNameText;
        TextView isAdminText;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            headImg = itemView.findViewById(R.id.head_img_view);
            nickNameText = itemView.findViewById(R.id.nick_name_text);
            isAdminText = itemView.findViewById(R.id.is_admin_text);
        }

    }
}
